package com.w2cx.selenium.operate;

import com.w2cx.selenium.base.DriverBase;
import com.w2cx.selenium.page.DestinationManagePage;
import org.openqa.selenium.WebElement;

import java.io.IOException;
import java.util.List;

public class DestinationManageOperate {

    DriverBase driver;
    DestinationManagePage dmp;
    public DestinationManageOperate(DriverBase driver){
        this.driver = driver;
        dmp = new DestinationManagePage(driver);
    }

    //点击“基础数据管理”菜单
    public void clickBaseDataManageMenu(){
        dmp.click(dmp.getBaseDataManageMenu());
    }

    //点击“目的地管理”菜单
    public void clickDestinationManageMenu(){
        dmp.click(dmp.getDestinationManageMenu());
    }




    //点击“添加”按钮
    public void clickAddDestiBtn(){
        dmp.click(dmp.getDestiAddBtn());
    }

    //输入目的地名称
    public void inputDestiName(String destiName){
        dmp.sendKeys(dmp.getDestiNameInput(),destiName);
    }


    //点击分类
    public void clickDestiCate(){
        dmp.click(dmp.getDestiCategory());
    }

    //选择分类
    public void selectCategory(){
        dmp.click(dmp.getCateSelect());

    }

    //点击“选择”按钮
    public void clickSelectBtn(){
        dmp.click(dmp.getSelectBtn());
    }

    //双击“北京市”
    public void doubleClickBJoption(){
        dmp.doubleClick(dmp.getBJOption());
    }

    //点击“确定”按钮
    public void clickSelectOptiConfriBtn(){
        dmp.click(dmp.getSelectBJConfirmBtn());
    }


    //点击添加缩略图按钮
    public void clickAddThumbnailBtn(){
        dmp.click(dmp.getAddThumbnailBtn());
    }


    //执行添加封面图脚本
    public void execAddImgScript(){
        //调用exe程序
        Runtime exe = Runtime.getRuntime();
       // String exeScript = "D:/upThumbnailImg.exe";
        String path = System.getProperty("user.dir");
        System.out.println("当前工程路径为："+path);
        //String exeScript = "D:/upThumbnailImg.exe";
        String exeScript = path+"\\"+"exe"+"\\"+"upThumbnailImg.exe";
        try {
            exe.exec(exeScript);
        } catch (IOException e) {
            e.printStackTrace();
        }

    }

    //点击确认按钮
    public void clickAddThumbConfirmBtn(){
        dmp.click(dmp.getAddThumbnailConfirmBtn());
    }

    //获取首行目的地名称
    public WebElement getFirstDestiName(){
        return dmp.getFirstDestiName();
    }


    //点击状态下拉框
    public void clickStatusDownList(){
        dmp.click(dmp.getStatusDownList());
    }


    //点击选项“正常”
    public void selectStatus(){
        dmp.click(dmp.getStatusSelect());
    }

    //点击分类下拉框
    public void clickCategoryDownList(){
        dmp.click(dmp.getCategoryDownList());
    }

    //选择分类
    public void selectSearchCategory(){
        dmp.click(dmp.getCateogrySelect());
    }

    //点击搜索按钮
    public void clickSearchBtn(){
        dmp.click(dmp.getSearchBtn());
    }

    //获取搜索结果列表
    public List<WebElement> getSearchResultList(){
        List<WebElement> list = dmp.getSearchResultList();
        return list;
    }

}
